const Router = require("koa-router");
const router = new Router({ prefix: "/document" });
const { validator } = require("../MiddleWare/validator");
const { FormatError } = require("../Constant/err.type");
const {
  create,
  remove,
  restore,
  find,
  reName,
  getPath,
  getInfo,
} = require("../Controller/document.controller");

// 新建文件接口
router.post(
  "/",
  validator(
    {
      docName: "string",
      fatherId: "number",
      docContain: "array",
      fatherName: "string",
      fileKind: "string",
    },
    FormatError
  ),
  create
);

// 删除文件接口
router.post("/:id/off", remove);
router.post("/:id/on", restore);

// 查找文件夹下文件接口
router.get("/:id", find);
// 重命名文件接口
router.post("/:id/rename", reName);
// 获取文件路径接口
router.post("/path/:id", getPath);
router.get("/:id/docinfo", getInfo);
module.exports = router;
